#ifndef NETTAO_DEFSQL_H
#define NETTAO_DEFSQL_H

#define SQL_LENGTH 1024 * 2

#define SQL_BATCH_LENGTH 1024 * 1024

#define SQL_ARTICLE_SELECT_BYNAME "select * from jieqi_article_article where articlename = '%s';"

#define SQL_ARTICLE_SELECT_LIST "select * from jieqi_article_article where lastupdate > %s order by lastupdate"

#define SQL_ARTICLE_SELECT_LIST_COUNT "select count(articleid) from jieqi_article_article "

#define SQL_ARTICLE_INSERT " insert into `jieqi_article_article` (\
`articleid`, `siteid`, `postdate`, `lastupdate`, `articlename`,`keywords`,\
`initial`, `authorid`, `author`, `posterid`,`poster`, `agentid`, \
`agent`, `sortid`, `typeid`, `intro`, `notice`, `setting`, \
`lastvolumeid`, `lastvolume`, `lastchapterid`, `lastchapter`,`chapters`, `size`,\
`lastvisit`, `dayvisit`, `weekvisit`, `monthvisit`,`allvisit`, `lastvote`,\
`dayvote`, `weekvote`, `monthvote`, `allvote`, `vipvotetime`, `vipvotenow`, \
`vipvotepreview`, `goodnum`, `badnum`, `toptime`, `saleprice`, `salenum`, \
`totalcost`, `articletype`, `permission`, `firstflag`, `fullflag`, `imgflag`,\
`power`, `display`,`downloadlink`)\
values ( \
%s,%s,%s,%s,'%s','%s',\
'%c',%s,'%s',%s,'%s',%s, \
'%s',%s,%s,'%s','%s','%s',\
%s,'%s',%s,'%s',%s,%s,\
%s,%s,%s,%s,%s,%s,\
%s,%s,%s,%s,%s,%s,\
%s,%s,%s,%s,%s,%s,\
%s,'%c','%c','%c','%c','%c',\
'%c','%c','%s');"

#define SQL_ARTICLE_UPDATE "update jieqi_article_article \
set `lastvolumeid`=%s, `lastvolume`='%s',`lastchapterid`=%s,`lastchapter`='%s', \
`chapters`=%s,`size`=%s \
where articleid=%s;" 

#define SQL_ARTICLE_MAXID "select max(articleid) articleid from jieqi_article_article "

#define SQL_CHAPTER_INSERT "INSERT INTO `jieqi_article_chapter`\
(`chapterid`,`siteid`,`articleid`,`articlename`,`volumeid`,\
`posterid`,`poster`,`postdate`,`lastupdate`,`chaptername`,\
`chapterorder`,`size`,`saleprice`,`salenum`,`totalcost`,\
`attachment`,`isvip`,`chaptertype`,`power`,`display`,`txtlink`)\
VALUES (\
%s,%s,%s,'%s',%s,\
%s,'%s',%s,%s,'%s',\
%s,%s,%s,%s,%s,\
'%s','%c','%c','%c','%c','%s');\r\n"

#define SQL_CHAPTER_SELECT "select * from jieqi_article_chapter where articleid=%s order by chapterorder;"

#define SQL_CHAPTER_SELECT_TIME "select * from jieqi_article_chapter where lastupdate >%s order by lastupdate limit %d;"

#define SQL_CHAPTER_MAXID "select max(chapterid)  chapterid from jieqi_article_chapter"

#endif